package com.yan;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author WangYan
 * @description:
 * @date 2021/7/5 20:48
 */
public class ConsumerApp {

    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-rabbit.xml");
        RabbitTemplate template = context.getBean(RabbitTemplate.class);

        Message message = template.receive("queue.q1.name.yan");

//        String contentEncoding = "utf-8";
        String contentEncoding = message.getMessageProperties().getContentEncoding();
        String msg = new String(message.getBody(), contentEncoding);
        System.out.println("---------" + msg);

        context.close();
    }

}
